﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using CrazyWorship1.PropertyHandler;
using CrazyWorship1.Class_Files.PropertyHandler;
using CrazyWorship1.Class_Files.Exceptions;

namespace CrazyWorship1.PropertyHandler
{
    /// <summary>
    /// Interaction logic for DoublePropertyHandler.xaml
    /// </summary>
    public partial class DoublePropertyHandler : PropertyHandlerControl
    {
        public DoublePropertyHandler()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
        {
            double temp;
            if (Double.TryParse(textBox1.Text, out temp))
                Value = textBox1.Text;
            else
                textBox1.Text = DefaultValue;
        }

        private void PropertyHandlerControl_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                textBox1.Text = DefaultValue;
                slider1.Value = Convert.ToDouble(DefaultValue);
            }
            catch (Exception)
            {
                throw new IncorrectPropertyDefaultException("Please ensure the " + this.SettingDebugInfo + " field is valid");
            }
        }
    }
   
}
